//package com.example.server.service.impl;
//
//import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
//import com.baomidou.mybatisplus.core.metadata.IPage;
//import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
//import com.example.server.mapper.EmployeeMapper;
//import com.example.common.pojo.Employee;
//import com.example.common.pojo.EmployeeEc;
//import com.example.server.mapper.EmployeeEcMapper;
//import com.example.server.service.IEmployeeEcService;
//import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
//import com.example.common.vo.RespBean;
//import com.example.common.vo.RespPageBean;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.stereotype.Service;
//
//import java.text.DecimalFormat;
//import java.time.LocalDate;
//import java.time.temporal.ChronoUnit;
//import java.util.List;
//import java.util.Map;
//
///**
// * <p>
// *  服务实现类
// * </p>
// *
// * @author 小红
// * @since 2022-09-02
// */
//@Service
//public class EmployeeEcServiceImpl extends ServiceImpl<EmployeeEcMapper, EmployeeEc> implements IEmployeeEcService {
//    @Autowired
//    private EmployeeMapper employeeMapper;
//
//    @Override
//    public RespPageBean getAll(Integer currentPage, Integer size, Employee employee) {
//
//        Page<Employee> page = new Page<>(currentPage, size);
//
//        IPage<Employee> result = employeeMapper.findAll(page, employee);
//        return new RespPageBean()
//                .setData(result.getRecords())
//                .setTotal(result.getTotal());
//    }
//
//    @Override
//    public RespBean maxWorkId() {
//        //select max(workId) from t_empolyee
//        List<Map<String, Object>> maps = employeeMapper.selectMaps(
//                new QueryWrapper<Employee>().select("max(workId)"));
//
//        String max = maps.get(0).get("max(workId)").toString();
//
//        int maxNum = Integer.parseInt(max) + 1;
//
//        String result = String.format("%08d", maxNum);
//        return RespBean.success(result);
//    }
//
//    @Override
//    public RespBean addEmp(Employee employee) {
//        LocalDate beginContract = employee.getBeginContract();
//        LocalDate endContract = employee.getEndContract();
//        long days = beginContract.until(endContract, ChronoUnit.DAYS);
//
//        DecimalFormat decimalFormat = new DecimalFormat("##.00");
//
//        String format = decimalFormat.format(days / 365.00);
//
//        employee.setContractTerm(Double.parseDouble(format));
//
//        int insert = employeeMapper.insert(employee);
//
//        return insert == 1 ? RespBean.success() : RespBean.error(503,"新增失败");
//    }
//}
